package com.biz.primus.ms.commodity.dao.po;

import com.biz.primus.base.enums.commodity.IStatus;
import com.biz.primus.ms.base.jpa.po.BaseEntityPKIncrement;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 商品自定义模块
 */
@Data
@Entity
@Table(name = "pro_commodity_custom_model")
public class CommodityCustomModel extends BaseEntityPKIncrement implements Serializable {

    @Column(length = 20)
    private String modelName;

    @Column
    private String description;

    @Column
    @Enumerated(EnumType.STRING)
    private IStatus status;

    @OneToMany(mappedBy = "commodityCustomModel")
    private List<Product> products;

    @Column
    private Long categoryId;

    @Column(columnDefinition = "TEXT")
    private String richText;

    public String getRichText() {
        if (IStatus.NORMAL.equals(this.status)){
            return richText;
        }else {
            return "";
        }
    }

}
